import { post, get } from '../http'
// -------------------------------广告组合-----------------------------
// 创建广告组合 ， 返回组合id
export const addpPortfolios = async (paylaod?: any) => {
  return await post('/adopr/v1/portfolios/add', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 广告组合列表
export const getPortfoliosList = async (paylaod?: any) => {
  return await post('/adopr/v1/portfolios/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 调整广告组合owner负责人
export const setPortfoliosOwner = async (paylaod?: any) => {
  return await post('/adopr/v1/portfolios/owner', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 广告组合列表-不分页-可以通过search查询
export const getAllPortfoliosList = async (paylaod?: any) => {
  return await get('/adopr/v1/portfolios/option', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 广告组合总体指标列表
export const portfoliosMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/portfolios/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 广告组合总体趋势图
export const portfoliosTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/portfolios/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// -------------------------------广告活动-----------------------------
// 广告活动列表
export const getCampaignList = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 获取基础广告活动信息
export const getCampaignBaseList = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/base/list', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 编辑广告活动（状态、日期、广告组合）
export const updateCampaign = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/state', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 广告活动总体指标
export const campaignMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 广告活动总体趋势图
export const campaignTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 广告活动数据对比-环比
export const campaignDateRangeContrast = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/dateRange/contrast', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 获取广告活动草稿列表
export const getCampaignDraftList = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/draft/list', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 删除广告活动草稿列表
export const deleteCampaignDraft = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/draft/delete', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 保存SP广告活动草稿箱
export const addCampaignDraft = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/draft/add', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 创建广告活动
export const addCampaign = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/add', paylaod, { backAllResult: true })
    .then((res) => res)
    .catch(() => false)
}
// 根据店铺id、活动id获取广告活动信息
export const getCampaignDetail = async (paylaod?: any) => {
  return await get('/adopr/v1/campaign/info/shopId/campaignId', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 编辑广告活动信息
export const editCampaign = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/edit', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 根据搜索词寻找活动名称
export const getAllCampaignList = async (paylaod?: any) => {
  return await get('/adopr/v1/campaign/option', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------分时策略-----------------------------

//分时策略应用分页列表
export const getPolicyList = async (paylaod?: any) => {
  return await post('/adopr/policy-targeting/list', paylaod, { isFilterData: true })
}
//批量操作应用对象
export const operationPolicyTargeting = async (paylaod?: any) => {
  return await post('/adopr/policy-targeting/operation', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//批量新增广告应用对象
export const savePolicyTargeting = async (paylaod?: any) => {
  return await post('/adopr/policy-targeting/batch/save', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//获取当前策略模板下的应用活动对象
export const getPolicyListByPolicyId = async (paylaod?: any) => {
  return await get('/adopr/policy-targeting/campaign/list', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//策略模板列表分页
export const getPolicyTemplateList = async (paylaod?: any) => {
  return await post('/adopr/policy-template/list', paylaod, { isFilterData: true })
}
//创建策略模板
export const createPolicyTemplateList = async (paylaod?: any) => {
  return await post('/adopr/policy-template/create', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//删除策略模板
export const deletePolicyTemplateList = async (paylaod?: any) => {
  return await post('/adopr/policy-template/delete', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//根据策略类型、搜索词获取策略下拉框-仅返回可用的
export const getPolicyOption = async (paylaod?: any) => {
  return await post('/adopr/policy-template/option', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//根据策略Id获取策略模板信息
export const getPolicyDetailById = async (paylaod?: any) => {
  return await get('/adopr/policy-template/get', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//批量新增广告应用对象-多类型
export const batchAddPolicyTargeting = async (paylaod?: any) => {
  return await post('/adopr/policy-targeting/batch/multiple/save', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//批量新增广告应用对象-多类型
export const getCampaignPolicy = async (paylaod?: any) => {
  return await get('/adopr/policy-targeting/campaign/get', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------广告组-----------------------------

//广告组列表
export const adGroupList = async (paylaod?: any) => {
  return await post('/adopr/v1/adGroup/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//广告组总体指标
export const adGroupMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/adGroup/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//广告组总体趋势图
export const adGroupTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/adGroup/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//广告组数据环比
export const adGroupContrast = async (paylaod?: any) => {
  return await post('/adopr/v1/adGroup/dateRange/contrast', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 调整广告组竞价或状态。0表示全部失败，1表示部分成功，2表示全部成功
export const updateAdGroup = async (paylaod?: any) => {
  return await post('/adopr/v1/adGroup/adjust', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 创建广告关键词 0(失败)1(部分成功)2(全部成功)
export const createKeyword = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/create', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 批量创建广告关键词 0(失败)1(部分成功)2(全部成功)
export const batchCreateKeyword = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/create/batch', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 根据店铺id和广告活动id获取广告组信息
export const getAdGroupByCampaignId = async (paylaod?: any) => {
  return await get('/adopr/v1/adGroup/info/shopId/campaignId', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 以广告组为主 获取广告活动-广告组tree
export const adGroupTree = async (paylaod?: any) => {
  return await get('/adopr/v1/campaign/tree', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 以广告组为主 获取广告活动-广告组tree
export const adGroupTreePage = async (paylaod?: any) => {
  return await get('/adopr/v1/campaign/page/tree', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 提交、创建广告组
export const createAdGroup = async (paylaod?: any) => {
  return await post('/adopr/v1/adGroup/create', paylaod, { backAllResult: true })
    .then((res) => res)
    .catch(() => false)
}
// 根据搜索词寻找广告组名称
export const getAllAdGroupList = async (paylaod?: any) => {
  return await get('/adopr/v1/adGroup/option', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------商品投放-----------------------------

// 获取基础广告目标投放信息
export const getTargetingBaseList = async (paylaod?: any) => {
  return await post('/adopr/v1/targeting/base/list', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------关键词-----------------------------

// 获取基础关键词列表信息
export const getKeywordBaseList = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/base/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//关键词列表
export const keywordList = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//关键词总体指标
export const keywordMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//关键词总体趋势图
export const keywordTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//关键词数据环比
export const keywordpContrast = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/dateRange/contrast', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//调整关键词竞价或状态 0(失败)1(部分成功)2(全部成功)
export const updateKeyword = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/adjust', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//获取广告关键词竞价建议列表
export const keywordRecommendation = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/recommendation', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------广告位-----------------------------

// 获取广告活动投放位列表
export const getPlacementList = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/placement/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 调整活动投放位竞价比例
export const updatePlacement = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/placement/adjust', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------商品列表-----------------------------

// 广告产品列表
export const getAdProductList = async (paylaod?: any) => {
  return await post('/adopr/v1/adProduct/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//广告产品总体指标
export const adProductMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/adProduct/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//广告产品总体趋势图
export const adProductTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/adProduct/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
//调整广告产品状态。0表示全部失败，1表示部分成功，2表示全部成功
export const updateAdProduct = async (paylaod?: any) => {
  return await post('/adopr/v1/adProduct/adjust', paylaod)
    .then((res) => res)
    .catch(() => false)
}
//创建广告产品--仅适用于SP、SD 0(失败)1(部分成功)2(全部成功)
export const createAdProduct = async (paylaod?: any) => {
  return await post('/adopr/v1/adProduct/create', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------否定关键词-----------------------------

// 广告否定关键词列表
export const negativeKeywordList = async (paylaod?: any) => {
  return await post('/adopr/v1/negativeKeyword/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 归档广告否定关键词 0(失败)1(部分成功)2(全部成功)
export const adjustNegativeKeyword = async (paylaod?: any) => {
  return await post('/adopr/v1/negativeKeyword/adjust', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 创建广告否定关键词 0(失败)1(部分成功)2(全部成功)
export const createNegativeKeyword = async (paylaod?: any) => {
  return await post('/adopr/v1/negativeKeyword/create', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 批量创建广告否定关键词 0(失败)1(部分成功)2(全部成功)
export const batchCreateNegativeKeyword = async (paylaod?: any) => {
  return await post('/adopr/v1/negativeKeyword/create/batch', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------搜索词-----------------------------

// 广告搜索词总体指标
export const searchTermMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/searchTerm/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 广告搜索词总体趋势图
export const searchTermTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/searchTerm/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 广告搜索词列表
export const searchTermList = async (paylaod?: any) => {
  return await post('/adopr/v1/searchTerm/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 创建创建广告关键词
export const batchCreateKeywordBySearchTerm = async (paylaod?: any) => {
  return await post('/adopr/v1/searchTerm/batch/create', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------自动投放-----------------------------

// 广告自动投放列表
export const targetingList = async (paylaod?: any) => {
  return await post('/adopr/v1/targeting/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 获取广告自动投放总体指标
export const targetingMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/targeting/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 广告自动投放总体趋势图
export const targetingTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/targeting/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 广告自动投放数据环比
export const targetingContrast = async (paylaod?: any) => {
  return await post('/adopr/v1/targeting/dateRange/contrast', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 获取广告活动投放竞价建议
export const recommendation = async (paylaod?: any) => {
  return await post('/adopr/v1/targeting/bid/campaign/recommendation', paylaod, { timeout: 60000 })
    .then((res) => res)
    .catch(() => false)
}
// 调整广告投放竞价或状态 0(失败)1(部分成功)2(全部成功)
export const targetingAdjust = async (paylaod?: any) => {
  return await post('/adopr/v1/targeting/adjust', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------数据看板-----------------------------

// 按时间段汇总出单量-站点
export const getMarketplaceGroupOrder = async (paylaod?: any) => {
  return await post('/finance/v1/bigdata/select/data/Order.Tongji.MarketplaceGroup', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 按时间段汇总出单量-sku
export const getSellerIdGroupOrder = async (paylaod?: any) => {
  return await post('/finance/v1/bigdata/select/data/Order.Tongji.SellerIdGroup', paylaod)
    .then((res) => res)
    .catch(() => false)
}

// -------------------------------广告看板-----------------------------
// 获取广告看板内总体指标
export const getOverallMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/dashboard/overall/metrics', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 获取广告看板趋势图
export const getOverallTrendCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/dashboard/overall/trendCharts', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 获取广告看板排行榜
export const getOverallRanking = async (paylaod?: any) => {
  return await post('/adopr/v1/dashboard/overall/ranking', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 获取关键词趋势指标-广告看板,默认ctr指标倒排
export const getOverallKeywordRanking = async (paylaod?: any) => {
  return await post('/adopr/v1/dashboard/overall/keyword/ranking', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// -------------------------------广告日志-----------------------------

// 获取亚马逊日志列表
export const getAdLogList = async (paylaod?: any) => {
  return await post('/adopr/v1/log/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 保存广告日志备注,返回大于 0 则表示成功
export const updateAdLogRemark = async (paylaod?: any) => {
  return await post('/adopr/v1/log/save/desc', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// -------------------------------高风险广告-----------------------------
// 高风险广告指标列表
export const riskPageListMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/risk/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 高风险广告列表
export const riskPageList = async (paylaod?: any) => {
  return await post('/adopr/v1/risk/page', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 调整风险看板
export const operationsAdjust = async (paylaod?: any) => {
  return await post('/adopr/v1/risk/operations/adjust', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// 获取广告看板数据操作记录明细-处理日志
export const operationsDetail = async (paylaod?: any) => {
  return await post('/adopr/v1/risk/operations/detail', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 获取风险看板详细评论-留言
export const commentDetail = async (paylaod?: any) => {
  return await post('/adopr/v1/risk/comment/detail', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 获取风险看板详细评论-新增留言
export const commentAdd = async (paylaod?: any) => {
  return await post('/adopr/v1/risk/comment/add', paylaod)
    .then((res) => res)
    .catch(() => false)
}
// -------------------------------关键词指标查询-----------------------------
// 关键词指标查询
export const getKeywordLibraryList = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/library/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 关键词库总体指标
export const getKeywordLibraryOverallMetrics = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/library/overall/metrics', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 关键词库趋势指标图表
export const getKeywordLibraryTrendOverallCharts = async (paylaod?: any) => {
  return await post('/adopr/v1/keyword/library/overall/trendCharts', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
// 获取当前店铺下面的广告组和广告活动信息
export const campaignShopList = async (paylaod?: any) => {
  return await post('/adopr/v1/campaign/shop/list', paylaod, { isFilterData: true })
    .then((res) => res)
    .catch(() => false)
}
